package cn.team11.smarteye.base;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import org.greenrobot.eventbus.EventBus;

import cn.team11.smarteye.utils.ToastUtil;

/**
 * Created by Murphy on 2017/10/19.
 */

public abstract class BaseFragment<T extends BasePresenter> extends Fragment implements BaseView<T> {

    protected T mBasePresenter;

    public FragmentListener mFragmentListener;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }



    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
    }


    @Override
    public void onAttach(Context context) {
        super.onAttach(context);

    }

    @Override
    public void onDetach() {
        super.onDetach();
    }

    public abstract void init();

    public interface FragmentListener {
        void setTitle(String title);
    }

    @Override
    public void showToast(int toastType, String str) {
        switch (toastType){
            case ToastUtil.NORMAL_TOAST:
                ToastUtil.showToast(str);
                break;
            case ToastUtil.NEGATIVE_TOAST:
                ToastUtil.showNegativeToast(str);
                break;
            case ToastUtil.POSITIVE_TOAST:
                ToastUtil.showPositiveToast(str);
        }
    }
}
